package com.lzw.breezeNovel.webApp.controller.video;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.model.entity.pojo.video.Danmu;
import com.lzw.breezeNovel.webApp.service.video.DanmuService;
import com.lzw.breezeNovel.webApp.vo.video.DanmuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.video
 * @date 2025/3/19
 * @description 弹幕的控制类
 */
@RestController
@RequestMapping("/app/video/danmu")
@SuppressWarnings("all")
public class DanmuController {

    /**
     * 注入弹幕service
     */
     @Autowired
     private DanmuService danmuService;

    /**
     * 添加弹幕
     */
    @RequestMapping("/add")
    public Result addDanmu(@RequestBody Danmu danmu){
         danmuService.addDanmu(danmu);
         return Result.ok();
    }

    /**
     * 获取所有的弹幕
     */
    @RequestMapping("/get")
    public Result<List<DanmuVo>> getDanmu(@RequestParam Integer videoId, @RequestParam Integer type, Integer episode){
        List<DanmuVo> danmus = danmuService.getDanmu(videoId, type,episode);
        return Result.ok(danmus);
    }


}
